import java.text.*;
import java.util.*;
import java.io.*;

class PosteriorProb {

  Forward fwd;

  Backward bwd;

  private double logprob;

  PosteriorProb(Forward fwd, Backward bwd) {
    this.fwd = fwd; this.bwd = bwd;
    logprob = fwd.logprob();
  }

  double posterior(int i, int k) { return Math.exp(fwd.f[i][k] + bwd.b[i][k] - logprob); }

}
